"""
内容:将商品货号封装成一个类

"""
#引入
from ECShop_no9.common.base import create_browser,Base,create_browser_op,base_sql_add
import time

class PageArticle01(Base):
    #属性
    # url = 'http://localhost:8080/ecshop/user.php'
    first = ('link text', '首页')
    sport_camera = ('xpath', ("//img[@src='images/201605/thumb_img/64_thumb_G_1462952811633.jpg']"))
    article_number=('xpath', ("//div[@class='textInfo']/form/ul/li[1]/dd[1]"))
    goods=('class','icon-goods')
    goods_keyword=('name','keyword')
    find_click=("xpath",("//div[@class='form-div']/form/button"))
    goods_number=("xpath",("//div[@class='list-div']/table/tbody/tr[3]/td[4]/span"))


    #方法
    #打开网页
    def page_article_number_web(self,url):
        self.base_open_web(url)
    #点击首页
    def page_article_number_first(self):
        self.base_click(self.first)
    #点击运动相机
    def page_article_number_sport_camera(self):
        self.base_click(self.sport_camera)
    #查询货号
    def page_article_number(self):
        result=self.base_get_text(self.article_number)
        result1=result.split('：')
        return result1[1]

    #关闭网页
    def page_article_number_quit(self):
        self.base_quit()

if __name__ == '__main__':
    a1=PageArticle01(create_browser_op(r'C:\Users\lenovo\AppData\Local\Google\Chrome\User Data'))
    # 打开网页
    a1.page_article_number_web('http://localhost:8080/ecshop/user.php')
    # 点击首页
    a1.page_article_number_first()
    # 点击运动相机
    a1.page_article_number_sport_camera()
    #获取商品货号
    res=a1.page_article_number()
    res1=res.split('：')
    print(res1)

    # time.sleep(6)
    # print(base_sql_add("SELECT * from ecs_goods where goods_name='运动相机'", 'goods_sn'))
    #退出
    a1.page_article_number_quit()
